#include <cstdio>

using namespace std; 

#define N 10088

int ra[N], rb[N]; 
int sign; 
int r[N]; 

void sub(int *a, int *b)
{
    int out; 

    for (int i=1; i<N; i++) {
    	int t; 
    	
    	if (a[i]>=b[i]) {
    	    t = a[i] - b[i]; 
    	} else {
    		a[i+1] --; 
    	    t = 10 + a[i] - b[i]; 
    	}
        r[i] = t; 
    }

    out = 0; 
    if (sign) 
    	printf("-"); 
    for (int i=N-1; i>=1; i--) {
        if (out || r[i]!=0 || i==1) {
            printf("%d", r[i]); 
            out = 1; 
        }
    }
    printf("\n"); 
}

void get_n(int *v, int *bits, int *high)
{
	int p, i; 
	
	static char tmp[N]; 
	
    fgets(tmp, N, stdin); 
	for (p=0; p<N; p++) {
		if (tmp[p]=='\0' || tmp[p]=='\n' || tmp[p]=='\r') 
			break; 
	}
	p--; 
	*bits = p; 
	*high = tmp[0] - '0'; 
	i=1; 
	while (p>=0 && i<N-1) {
		v[i] = tmp[p] - '0'; 
		i++; 
		p--; 
	}
	v[i] = '\0'; 
}

int main()
{
	int bits_a, bits_b, high_a, high_b; 
	get_n(ra, &bits_a, &high_a); 
	get_n(rb, &bits_b, &high_b); 
	if (bits_a>bits_b || (bits_a==bits_b && high_a>=high_b)) {
    	sub(ra, rb);
    } else {
    	sign = 1; 
    	sub(rb, ra);
    }
    return 0; 
}


